<html>
<body>
  <div id="signature"></div>
</body>
</html>
<script type="text/javascript" src="./webmssdk.es5.js"></script>
<script type="text/javascript">
var room_id = getUrlParam('room_id');
var e = stringToBytes("live_id=1,aid=6383,version_code=180800,webcast_sdk_version=1.0.10,room_id="+room_id+",sub_room_id=,sub_channel_id=,did_rule=3,user_unique_id=7293456606909236748,device_platform=web,device_type=,ac=,identity=audience");
for (var s = bytesToWords(e), u = 8 * e.length, l = 1732584193, c = -271733879, h = -1732584194, f = 271733878, d = 0; d < s.length; d++)s[d] = (s[d] << 8 | s[d] >>> 24) & 16711935 | (s[d] << 24 | s[d] >>> 8) & 4278255360;

    s[u >>> 5] |= 128 << u % 32,
    s[(u + 64 >>> 9 << 4) + 14] = u;

    for (var p = _ff, _ = _gg, g = _hh, m = _ii, d = 0; d < s.length; d += 16) {
        var y = l
          , T = c
          , E = h
          , v = f;
        l = p(l, c, h, f, s[d + 0], 7, -680876936),
        f = p(f, l, c, h, s[d + 1], 12, -389564586),
        h = p(h, f, l, c, s[d + 2], 17, 606105819),
        c = p(c, h, f, l, s[d + 3], 22, -1044525330),
        l = p(l, c, h, f, s[d + 4], 7, -176418897),
        f = p(f, l, c, h, s[d + 5], 12, 1200080426),
        h = p(h, f, l, c, s[d + 6], 17, -1473231341),
        c = p(c, h, f, l, s[d + 7], 22, -45705983),
        l = p(l, c, h, f, s[d + 8], 7, 1770035416),
        f = p(f, l, c, h, s[d + 9], 12, -1958414417),
        h = p(h, f, l, c, s[d + 10], 17, -42063),
        c = p(c, h, f, l, s[d + 11], 22, -1990404162),
        l = p(l, c, h, f, s[d + 12], 7, 1804603682),
        f = p(f, l, c, h, s[d + 13], 12, -40341101),
        h = p(h, f, l, c, s[d + 14], 17, -1502002290),
        c = p(c, h, f, l, s[d + 15], 22, 1236535329),
        l = _(l, c, h, f, s[d + 1], 5, -165796510),
        f = _(f, l, c, h, s[d + 6], 9, -1069501632),
        h = _(h, f, l, c, s[d + 11], 14, 643717713),
        c = _(c, h, f, l, s[d + 0], 20, -373897302),
        l = _(l, c, h, f, s[d + 5], 5, -701558691),
        f = _(f, l, c, h, s[d + 10], 9, 38016083),
        h = _(h, f, l, c, s[d + 15], 14, -660478335),
        c = _(c, h, f, l, s[d + 4], 20, -405537848),
        l = _(l, c, h, f, s[d + 9], 5, 568446438),
        f = _(f, l, c, h, s[d + 14], 9, -1019803690),
        h = _(h, f, l, c, s[d + 3], 14, -187363961),
        c = _(c, h, f, l, s[d + 8], 20, 1163531501),
        l = _(l, c, h, f, s[d + 13], 5, -1444681467),
        f = _(f, l, c, h, s[d + 2], 9, -51403784),
        h = _(h, f, l, c, s[d + 7], 14, 1735328473),
        c = _(c, h, f, l, s[d + 12], 20, -1926607734),
        l = g(l, c, h, f, s[d + 5], 4, -378558),
        f = g(f, l, c, h, s[d + 8], 11, -2022574463),
        h = g(h, f, l, c, s[d + 11], 16, 1839030562),
        c = g(c, h, f, l, s[d + 14], 23, -35309556),
        l = g(l, c, h, f, s[d + 1], 4, -1530992060),
        f = g(f, l, c, h, s[d + 4], 11, 1272893353),
        h = g(h, f, l, c, s[d + 7], 16, -155497632),
        c = g(c, h, f, l, s[d + 10], 23, -1094730640),
        l = g(l, c, h, f, s[d + 13], 4, 681279174),
        f = g(f, l, c, h, s[d + 0], 11, -358537222),
        h = g(h, f, l, c, s[d + 3], 16, -722521979),
        c = g(c, h, f, l, s[d + 6], 23, 76029189),
        l = g(l, c, h, f, s[d + 9], 4, -640364487),
        f = g(f, l, c, h, s[d + 12], 11, -421815835),
        h = g(h, f, l, c, s[d + 15], 16, 530742520),
        c = g(c, h, f, l, s[d + 2], 23, -995338651),
        l = m(l, c, h, f, s[d + 0], 6, -198630844),
        f = m(f, l, c, h, s[d + 7], 10, 1126891415),
        h = m(h, f, l, c, s[d + 14], 15, -1416354905),
        c = m(c, h, f, l, s[d + 5], 21, -57434055),
        l = m(l, c, h, f, s[d + 12], 6, 1700485571),
        f = m(f, l, c, h, s[d + 3], 10, -1894986606),
        h = m(h, f, l, c, s[d + 10], 15, -1051523),
        c = m(c, h, f, l, s[d + 1], 21, -2054922799),
        l = m(l, c, h, f, s[d + 8], 6, 1873313359),
        f = m(f, l, c, h, s[d + 15], 10, -30611744),
        h = m(h, f, l, c, s[d + 6], 15, -1560198380),
        c = m(c, h, f, l, s[d + 13], 21, 1309151649),
        l = m(l, c, h, f, s[d + 4], 6, -145523070),
        f = m(f, l, c, h, s[d + 11], 10, -1120210379),
        h = m(h, f, l, c, s[d + 2], 15, 718787259),
        c = m(c, h, f, l, s[d + 9], 21, -343485551),
        l = l + y >>> 0,
        c = c + T >>> 0,
        h = h + E >>> 0,
        f = f + v >>> 0
    }
    var stub = {
      "X-MS-STUB": bytesToHex(wordsToBytes(endian([l, c, h, f])))
    };

var signature = window.byted_acrawler.frontierSign(stub)["X-Bogus"];
document.getElementById('signature').innerHTML = signature;

var url = "wss://webcast5-ws-web-hl.douyin.com/webcast/im/push/v2/?app_name=douyin_web&version_code=180800&webcast_sdk_version=1.0.10&update_version_code=1.0.10&compress=gzip&device_platform=web&cookie_enabled=true&screen_width=1920&screen_height=1080&browser_language=zh-CN&browser_platform=Win32&browser_name=Mozilla&browser_version=5.0%20(Windows%20NT%2010.0;%20Win64;%20x64)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/118.0.0.0%20Safari/537.36%20Edg/118.0.2088.69&browser_online=true&tz_name=Asia/Shanghai&cursor=r-1_d-1_u-1_fh-7294507099622085669_t-1698384834280&internal_ext=internal_src:dim|wss_push_room_id:"+room_id+"|wss_push_did:7293456606909236748|dim_log_id:202310271333541DC3CE7F472C391171F5|first_req_ms:1698384834190|fetch_time:1698384834280|seq:1|wss_info:0-1698384834281-0-0|wrds_kvs:WebcastRoomStatsMessage-1698384825265668451_WebcastInRoomBannerMessage-GrowthCommonBannerSubSyncKey-1698381333404075821_HighlightContainerSyncData-16_InputPanelComponentSyncData-1698371798814602649_AudienceGiftSyncData-1698384804163809534_WebcastRoomRankMessage-1698384051244334807&host=https://live.douyin.com&aid=6383&live_id=1&did_rule=3&endpoint=live_pc&support_wrds=1&user_unique_id=7293456606909236748&im_path=/webcast/im/fetch/&identity=audience&need_persist_msg_count=15&room_id="+room_id+"&heartbeatDuration=0&signature=" + signature;
var ws = new WebSocket(url); 
ws.onmessage = function(e){
  console.log(e.data);
}

function stringToBytes(e){
  for (var t = [], n = 0; n < e.length; n++)
            t.push(255 & e.charCodeAt(n));
        return t
}
function bytesToWords(e){
  for (var t = [], n = 0, r = 0; n < e.length; n++, r += 8)
            t[r >>> 5] |= e[n] << 24 - r % 32;
        return t
}
function wordsToBytes(e){
        for (var t = [], n = 0; n < 32 * e.length; n += 8)
            t.push(e[n >>> 5] >>> 24 - n % 32 & 255);
        return t
    }
    function bytesToHex(e){
        for (var t = [], n = 0; n < e.length; n++)
            t.push((e[n] >>> 4).toString(16)),
            t.push((15 & e[n]).toString(16));
        return t.join("")
    }
function endian(e){
  if (e.constructor == Number)
            return 16711935 & rotl(e, 8) | 4278255360 & rotl(e, 24);
        for (var t = 0; t < e.length; t++)
            e[t] = endian(e[t]);
        return e
}
function rotl(e, t){
        return e << t | e >>> 32 - t
    }
function _ff(e, t, n, r, i, o, a){
        var s = e + (t & n | ~t & r) + (i >>> 0) + a;
        return (s << o | s >>> 32 - o) + t
    }
    function _gg(e, t, n, r, i, o, a){
        var s = e + (t & r | n & ~r) + (i >>> 0) + a;
        return (s << o | s >>> 32 - o) + t
    }
    function _hh(e, t, n, r, i, o, a){
        var s = e + (t ^ n ^ r) + (i >>> 0) + a;
        return (s << o | s >>> 32 - o) + t
    }
    function _ii(e, t, n, r, i, o, a){
        var s = e + (n ^ (t | ~r)) + (i >>> 0) + a;
        return (s << o | s >>> 32 - o) + t
    }
    function getUrlParam(name) {
    //¹¹ÔìÒ»¸öº¬ÓÐÄ¿±ê²ÎÊýµÄÕýÔò±í´ïÊ½¶ÔÏó
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    //Æ¥ÅäÄ¿±ê²ÎÊý
    var r = window.location.search.substr(1).match(reg);
    //·µ»Ø²ÎÊýÖµ
    if(r != null) {
        return decodeURI(r[2]);
    }
    return null;
}
</script>